def cell_division(n):
    if cell[n]!=0:
        return cell[n]
    result=0
    if n==1 or n==2 or n==3:
        return 1
    else:
        result=cell_division(n-1)+cell_division(n-3)
    cell[n]=result
    return result



if __name__=="__main__":
    cell=[]
    for i in range(51):
        cell.append(0)

    while True:
        n=int(input().strip())
        if n==0:
            break
        print(cell_division(n))